#!/usr/bin/env bash

__rvm_rvmrc_to()
{
  case "${1:-help}" in
    (.ruby-version|ruby-version)
      __rvm_rvmrc_to_ruby_version || return $?
      ;;
    (help)
      rvm_help rvmrc to
      return 0
      ;;
    (*)
      rvm_error_help "Unknown subcommand '$1'" rvmrc to
      return 1
      ;;
  esac
}

__rvm_rvmrc_to_ruby_version()
(
  [[ -s "$PWD/.rvmrc" ]] ||
  {
    rvm_error "No .rvmrc to convert"
    return 2
  }
  __rvm_load_project_config "$PWD/.rvmrc" ||
  {
    rvm_error "Could not load .rvmrc"
    return 3
  }

  __rvm_set_ruby_version

  \command \rm .rvmrc ||
  {
    rvm_error "Could not remove .rvmrc"
    return 4
  }
)
